#ifndef _CONTRA_GAME_H_
#define _CONTRA_GAME_H_

#include <d3dx9.h>

#include "Game.h"
#include "Sprite.h"
#include "Simon.h"
#include "Camera.h"
#include "QuadTree.h"
#include "LoadMap.h"
#include "Info.h"
#include "Score.h"
#include "dxaudio.h"
#include "TilesObject.h"

class Simon;
/**--------------------------------------------------------
*Program/Project : CastleVaniaGame
*Written by :
*Email :
*Created date : 7/10/2012
*Modified by :
*Modified date :
*Version : 1.0
*Description : Lop khoi tao MarioManager
--------------------------------------------------------**/

class ContraGame : public Game
{
public:
	LPD3DXSPRITE _spriteHandler;	// SpriteHandler to draw texture

	/*
	*	Constructor
	*/
	CastleVaniaGame(HINSTANCE hInstance, LPWSTR Name, int Mode, int IsFullScreen, int FrameRate);
	~CastleVaniaGame();


	int num_score;					//score game
	int num_life;					//number life of mario
	int num_heart;					//number coin of mario
	int count_time;					//time to complete level
	int reset_time;					//time reset game-state
	int count_time_random;

	vector<string> map_vt;			//save cac map

	int game_state;					//trang thai game
	int map_current;				//map chinh dang choi
	bool is_change_map;				//kiem tra chuyen map lon

	int submap;						//map phu
	int subMapToMap;				//kiem tra co chuyen tu map phu sang map chinh k
	bool is_replay;					//kiem tra game co dc choi lai k


	int time_change_map;
	int is_load_game;				//kiem tra load game dau tien hay choi roi moi load game?

	int xPointMenu, yPointMenu;		//con tro menu	
	Sprite* pointMenu;				//sprite con tro menu

	Simon* p_player;
	int simon_axe_version;
	int simon_rod_version;
	int simon_blood;
	int boss_blood;



	//Camera
	Camera *camera;		//camera game
	int width_map;		//chieu rong cua map hien tai

	//Random enemy object
	list<Object*> random_enemy_list;
	list<Object*> random_enemy_list_remove;

	//Object
	LoadMap *load_quadtree_obj;
	QuadTree *quadtree;
	list<Object*> obj_list;
	list<Object*> obj_list_save;

	//Hinh bg
	LoadMap *load_quadtree_tiles;
	QuadTree *quadtree_tiles;
	list<TilesObject*> tiles_list;
	Sprite* p_spriteBg;


	/*
	*	Hien thi Diem, Mang,..
	*/
	Info* infoArr[8];
	Score* scoreArr[6];
	list<Score*> scoreList;
	list<Score*> scoreRemoveList;
	Info* info_blood_player[8];
	Info* info_death_player[8];
	Info* info_blood_boss[8];
	Info* info_death_boss[8];

	Info* info_weapon[5];	//vu khi cua simon

	/*
	*	Am thanh
	*/
	DxAudio *dxAudio;
	CSound *background_sound, *rod_sound, *eat_item, *bumpSound, *coinSound, *deathSound, *fireballSound, *gameOverSound;
	CSound *jumpSound, *kickSound, *lifeSound, *mipSound, *pipeWarpSound, *powerupSound, *startGameSound, *winGameSound;

	/*
	*	Method
	*/
	virtual void LoadResources(LPDIRECT3DDEVICE9 d3ddv, LPDIRECT3DSURFACE9 BackBuffer);

	virtual void ProcessInput(LPDIRECT3DDEVICE9 d3ddv, int Delta);
	virtual void update(LPDIRECT3DDEVICE9 d3ddv, LPDIRECT3DSURFACE9 BackBuffer, int Delta);

	virtual void RenderFrame(LPDIRECT3DDEVICE9 d3ddv, LPDIRECT3DSURFACE9 BackBuffer, int Delta);

	//Info score when simon eat items
	void InfoScore(int score, int x, int y);

	//Change state game
	void ChangeState(int state);

	//Change map
	void ChangeMap(int map);
	void ChangeSubMap(int submap);

	//Background Tiles
	void LoadBackground(char* tiles_file);
	void RenderBackground();

	//Generate random enemy object
	void GenerateRandomEnemy(RECT camera);

	//Save map
	void SaveMap(char* file_name);
	vector<string> LoadSaveMap(char* file_name);
};


#endif

